using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class XRK : Plant
{
    public float CrateTime = 5;
    private float CrateTimer = 0;
    private Animator anim;
    public GameObject Sun;
    public float JumpMax = 1f;
    public float JumpMin = 0.5f;
    private void Awake()
    {
        anim = GetComponent<Animator>();
    }
    protected override void EnableUpdate()
    {
        CrateTimer += Time.deltaTime;
        if (CrateTimer > CrateTime)
        {
            CrateTimer = 0;
            anim.SetTrigger("isGrowing");
        }
    }
    public void CrateSun()
    {
        GameObject go = GameObject.Instantiate(Sun, transform.position, Quaternion.identity);

        float jump = Random.Range(JumpMin, JumpMax);
        jump = Random.Range(0, 2) < 1 ? -jump : jump;
        Vector3 position = transform.position;
        position.x += jump;
        go.GetComponent<Sun>().JumpTo(position);
    }
}
